<?php
include('db.php');
$db = getDb();

$content=file_get_contents("../view/newSubevent.html");
$_MAILS_="_MAILS_";
$_MAILS_content="";

$_ID_="_ID_";
$_ID_content=$_GET['id'];

	$_MAILS_content .= "<option value=\"-\">---GROUPS---</option>\n";

	$sqlCommand="SELECT id,name FROM groups";
	$result = $db->Execute($sqlCommand);
	
	if ($result === false)
		die($sqlCommand);
	
	while (!$result->EOF)
	{
		$_MAILS_content .= "<option value=\"g" . $result->fields[0] .
		"\">" . $result->fields[1] . "</option>\n";
		$result->MoveNext();
	}

	
	$_MAILS_content .= "<option value=\"-\">---EMAILS---</option>\n";
	
	$sqlCommand="SELECT id,address,name FROM email";
	$result = $db->Execute($sqlCommand);
	
	if ($result === false)
		die($sqlCommand);
	
	while (!$result->EOF)
	{
		$_MAILS_content.= "<option value=\"e" . $result->fields[0] .
		"\">" . $result->fields[1]  . "(". $result->fields[2]  .")</option>\n";
			
		$result->MoveNext();
	}


	$content = str_replace($_ID_ , $_ID_content, $content);
	$content = str_replace($_MAILS_ , $_MAILS_content, $content);
	
 // Display page
 echo $content;
 
?>
